home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11601 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  55 lines

  1. Path: news.uh.edu!usenet
  2. From: Sensarn <txs53132@bayou.uh.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: Inline Assembler and OOP
  5. Date: 15 Mar 1996 04:06:47 GMT
  6. Organization: AEtna Insurance Agency
  7. Message-ID: <4iaqcn$mfu@masala.cc.uh.edu>
  8. NNTP-Posting-Host: sip-16661.public-dialups.uh.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.1 (Windows; U; 16bit)
  13.  
  14. Are there any restrictions on class data members when used in the asm {} 
  15. block?  I have this:
  16.  
  17. struct double_buffer {
  18. private:
  19.     unsigned char *buffer; /* Actual data */
  20.     unsigned int buffer_height; /* Height of buffer in pixels */
  21.     unsigned int buffer_width; /* Width of buffer in pixels */
  22.     unsigned int buffer_size; /* Actual size of buffer */
  23. public:
  24.     double_buffer(int num_lines=200); /* Constructor */
  25.     ~double_buffer(void); /* Destructor */
  26.     void show(void); /* Display double buffer */
  27. };
  28.  
  29. Okay -- everything is fine.  Now I have my constructor:
  30.  
  31. double_buffer::double_buffer(int num_lines) {
  32.     buffer_size=(long int)320*num_lines+1;
  33.     buffer=(unsigned char far *)farmalloc(buffer_size);
  34.     asm {
  35.         les di,buffer /* Expression syntax error here */
  36.         mov cx,buffer_size/2 /* Here too */
  37.         xor ax,ax
  38.         cld
  39.         rep stosw
  40.     }
  41. }
  42.  
  43. Is there some reason why I cannot access buffer and buffer_size in the 
  44. asm statement (even though the asm statement is inside a member 
  45. function).  I even tried making them both public!
  46.  
  47. -- 
  48. ______________________________
  49.  
  50. Steven Sensarn
  51. E-Mail - txs53132@bayou.uh.edu
  52. ______________________________
  53.  
  54.  
  55.